package com.tau.egonetwork.profiles;

import java.util.ArrayList;

public class FriendsList<T extends Comparable<T>> extends ArrayList<Profile<T>> {
	
	private static final long serialVersionUID = -6456189592991257712L;

	@SuppressWarnings("unchecked")
	@Override
	public boolean contains(Object o) {
		if (!(o instanceof Profile))
			return false;
		Profile<T> p = (Profile<T>)o;
		for (Profile<T> pp : this) {
			if (pp.getID() == p.getID()) {
				return true;
			}
		}
		return false;
	}
	
	public Profile<T> get(T id) {
		for (Profile<T> p : this) {
			if (p.getID().compareTo(id) == 0) {
				return p;
			}
		}
		return null;
	}
	
	public Profile<T> getByName(String name) {
		for (Profile<T> p : this) {
			if (p.getName().equals(name)) {
				return p;
			}
		}
		return null;		
	}
	
}
